vcRaycast

vcRaycast provides functionality for casting rays.

See in: Overview

Module: vcCore

Parent: -

Children -

Referenced by: -

Methods

Learn how to use methods here. The methods are also inherited from the parent class.

NameReturn TypeParametersDescription
raycastListvcRaycastResultList[vcNodeListEntry] nodeList,
vcMatrix position,
Real rayLength,
Optional Keyword[pickBackface = Boolean]
Tests if a ray intersects an object in the provided list.

The position of the ray is based in the world coordinate system,
and the length of the ray is directed along the positive Z-axis.
See more
Parameters:
nodeList (list[vcNodeListEntry]): A list of vcNodeListEntry objects controlling which nodes are excluded or included.
position (vcMatrix): The position and orientation of the ray.
rayLength (float): The length of the ray.
Optional: pickBackface (bool): An optional argument which controls whether to include geometry backfaces in ray casting or not. The default value is True.

Returns:
vcRaycastResult: The result of the raycast operation.
raycastScenevcRaycastResultvcMatrix position,
Real rayLength,
Optional Keyword[pickBackface = Boolean],
Optional Keyword[excludeNode = vcNode]
Tests if a ray intersects an object in the active scene.

The position of the ray is based in the world coordinate system,
and the length of the ray is directed along the positive Z-axis.
See more
Parameters:
position (vcMatrix): The position and orientation of the ray.
rayLength (float): The length of the ray.
Optional: pickBackface (bool): An optional argument which controls whether to include geometry backfaces in ray casting or not. The default value is True.
Optional: excludeNode (vcNode): An optional argument to exclude a node, thereby allowing the ray to cast through and ignore collision with the given node and its child nodes. The default value is None.

Returns:
vcRaycastResult: The result of the raycast operation.

Example: Raycast Intersection Test

"""This example shows how to test if a ray intersects with geometry within 50 mm range of the start position."""

import vcCore as vc

# Start by creating a link and a block feature inside it.
# The geometry inside the link is excluded from the raycast test. Geometry that belongs to other nodes is detected in the raycast test.

async def OnRun():
  comp = vc.getComponent()
  node = comp.findNode("Link_1") # Geometry inside this node will be excluded from the raycast test.

  m = vc.vcMatrix.new()
  start_position = vc.vcVector.new(50, 50, 50)
  m.P = start_position # Ray starts from 50, 50, 50 and points to +Z direction

  result = vc.vcRaycast.raycastScene(m, 50.0, excludeNode=node) # Test if ray intersects with geometry within 50 mm range of the start position.
  print("--------")
  print(result.Hit)
  print(result.Node)
  print(result.Position)
  print(result.Set)